using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MH.WsdlWorks
{
    public partial class WsdlFromUrlDialog : Form
    {
        WsdlFromUrlResult result;

        public WsdlFromUrlDialog()
        {
            InitializeComponent();
        }

        public WsdlFromUrlResult GetWsdl()
        {
            this.result = new WsdlFromUrlResult(null, true);
            this.ShowDialog();
            return result;
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.result = new WsdlFromUrlResult(new Uri(this.urlTextBox.Text), false);
                this.Close();
            }
            catch (UriFormatException)
            {
                MessageBox.Show("Please enter a valid URL for the WSDL file");
            }
        }
    }

    public struct WsdlFromUrlResult
    {
        readonly public Uri Url;
        readonly public bool Cancelled;

        public WsdlFromUrlResult(Uri url, bool cancelled)
        {
            this.Url = url;
            this.Cancelled = cancelled;
        }
    }
}